package org.neuedu.chapter09_0701.practice05;

import java.util.Scanner;

public class MailTest {
    public static void main(String[] args) {
        while(true){
            Scanner scanner = new Scanner(System.in);
            System.out.println("please input email address : ");
            String email = scanner.nextLine();
            if (!email.contains("@") || !email.contains(".")) {
                System.out.println("邮箱地址中不包含@或.");
            } else if (email.indexOf("@") != email.lastIndexOf("@") || email.indexOf(".") != email.lastIndexOf(".")) {
                System.out.println("邮箱地址中含有多个@或.");
            } else if (email.indexOf("@") > email.indexOf(".")) {
                System.out.println("邮箱地址中.出现在@的前面");
            } else{
                System.out.println("恭喜，合法邮箱：" + email);
            }
        }
    }
}
